package com.zfzs.post.modules.excel.rest;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.modules.excel.service.ExlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 上传导入管理
 *
 * @author: ck
 * @create: 2019-12-05 11:13
 **/
@RestController
@RequestMapping("excel")
public class ExlController {

    @Autowired
    private ExlService exlService;

    /**
     * 终端导入
     *
     * @param attach
     * @return
     */
    @Log("终端通用数据导入")
    @RequestMapping(value = "/uploadTerminalExcel", method = RequestMethod.POST)
    public ResponseResult uploadTerminalExcel(@RequestParam("file") MultipartFile attach, Long terminalId) {
        int res = exlService.uploadTerminalExcel(attach, terminalId);
        return ResponseResult.ok(res);
    }

    /**
     * 交易通用数据导入
     *
     * @param attach
     * @param terminalId
     * @return
     */
    @Log("交易通用数据导入")
    @RequestMapping(value = "/uploadTransactionExcel", method = RequestMethod.POST)
    public ResponseResult uploadTransactionExcel(@RequestParam("file") MultipartFile attach, Long terminalId) {
        int res = exlService.uploadTransactionExcel(attach, terminalId);
        return ResponseResult.ok(res);
    }
}
